package com.felix.file;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.felix.util.JacksonUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * Demo
 *
 * @author xjh
 * @version 1.0
 * @date 2019-03-18
 */
@Slf4j
public class Demo {


    public static void main(String[] args) throws IOException {
        File file = new File("D:\\solarProjects.txt");
        String solarProjectsJson = FileUtils.readFileToString(file, "utf-8");
        List<Project> projects = JacksonUtils.json2list(solarProjectsJson, Project.class);
        File file1 = new File("D:\\windProjects.txt");
        String windProjectsJson = FileUtils.readFileToString(file1, "utf-8");
        projects.addAll(JacksonUtils.json2list(windProjectsJson, Project.class));
        String json = JacksonUtils.obj2json(projects);
    }
}

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
class Project {
    private String name;
    private String masterId;
}
